import React, { Component } from 'react'
import ChildCom from './5-ChildCom'

export default class ZongJieCom extends Component {
  state = {
    count: 1
  }
  render() {
    return (
      <div>
        <h2>{this.state.count}</h2>
        <hr />
        <ChildCom count={this.state.count} />
        <hr />
        <button onClick={() => {
          //更新状态 自增 count
          this.setState({
            count: this.state.count + 1
          })
        }}>自增</button>
        <button onClick={() => {
          //自减 count 的值
          this.state.count -= 1;
          // console.log(this.state.count);
          this.forceUpdate();// force 强制  update 更新

        }}>自减</button>
      </div>
    )
  }
}
